﻿using System.Xml.Linq;
using FarseerGames.FarseerPhysics.Mathematics;
using FreeGoo.GameEngine;
using FreeGoo.GameEngine.Renderables;
using FreeGoo.GameEngine.Renderables.BodyHookOwners;

namespace FreeGoo.LevelClasses.LevelParts.BodyHookOwners
{
    public class MotorLevelPart : BodyRenderableLevelPart
    {
        public override string Name { get { return "Motor"; } }

        public override BodyRenderable BuildBodyRenderable(Level level, XElement element)
        {
            Motor motor;
            Vector2 position = GetOffsetPosition(level, element);
            float hookRadius = element.Attribute("BodyHookRadius").ToFloat(150);
            int hookCount = element.Attribute("BodyHookCount").ToInt(6);

            motor = MixedFactory.CreateMotor(
                level.Engine,
                position,
                hookRadius,
                hookCount);
            motor.TargetAngularVelocity = 3;
            return motor;
        }
    }
}
